float3 LightPosition;
float3 CameraPosition;

float4 DiffuseColor;
float3 EmissiveColor;	
float3 AmbientColor;			
float4 SpecularColor;

float4 Booleans01;				// x = Diffuse

// Structs

struct VS_OUTPUT
{
    float4 position				: POSITION;
	float3 positionW			: TEXCOORD0;
	float3 normalW				: TEXCOORD1;
	float4 color				: COLOR0;
};


// Shaders
float4 main(VS_OUTPUT In) : COLOR
{
	float3 baseColor = In.color;
	float3 normalW = normalize(In.normalW);



	// Diffuse Lighting
	float3 lightDirectionW = normalize(LightPosition - In.positionW);
	float ndl = max(0, dot(normalW, lightDirectionW));
	float3 diffuse = baseColor.rgb * ndl;

	// Specular Lighting	
	float3 specularColor = SpecularColor.rgb;
	float3 viewDirectionW = normalize(CameraPosition - In.positionW);
	float3 reflectionVector = normalize(reflect(-lightDirectionW, normalW));
	float specComp = pow(saturate(dot(reflectionVector, viewDirectionW)), SpecularColor.a);


	float3 specular = specularColor * specComp;
	
	// Final
	return float4(saturate(saturate(diffuse +  EmissiveColor) + AmbientColor) * baseColor + specular, DiffuseColor.a);
}